<?php
/*! \brief
 * This is WFWidgetInfoXmlManager class
 * This is the Class that manipulate file /path/to/repository/widgets_new_info.xml
 * \author William Su
 */
class WFWidgetInfoXmlManager
{
    /**
     * @var WF
     */
    protected $objFramework;
    protected $strPathWidgetInfoXmlFromWpCurrent;
    protected $strPathWidgetInfoXmlFromWidgetsNew;
    public function __construct($objFramework){
        $this->objFramework = $objFramework;
        $this->strPathWidgetInfoXmlFromWpCurrent = $this->objFramework->getWPHome() . '/widget/widget_info.xml';
        $this->strPathWidgetInfoXmlFromWidgetsNew = $this->objFramework->getDocumentRoot() . '/repository/widgets_new/widget/widget_info.xml';
    }
    /**
     *\brief Description
     * - This method will get widget_info->configure_widget_version value from /path/to/repository/widget_new/widget_info.xml
     */
    public function getConfigureWidgetVersionFromWidgetsNew(){
        $ret = '';
        $isFileExists = $this->objFramework->getIOFactory()->getFile()->isFileExists($this->strPathWidgetInfoXmlFromWidgetsNew);
        if(true === $isFileExists){
            $elWidgetInfo = new SimpleXMLElement($this->strPathWidgetInfoXmlFromWidgetsNew, null, true);
            $ret = $elWidgetInfo[0]->configure_widget_version;
            $ret = (string) $ret;
        }
        return $ret;
    }
    /**
     *\brief Description
     * - This method will get widget_info->configure_widget_version value from /path/to/repository/widgetPool/wpCurrent/widget/widget_info.xml
     */
    public function getConfigureWidgetVersionFromWpCurrent(){
        $ret = '';
        $isFileExists = $this->objFramework->getIOFactory()->getFile()->isFileExists($this->strPathWidgetInfoXmlFromWpCurrent);
        if(true === $isFileExists){
            $elWidgetInfo = new SimpleXMLElement($this->strPathWidgetInfoXmlFromWpCurrent, null, true);
            $ret = $elWidgetInfo[0]->configure_widget_version;
            $ret = (string) $ret;
        }
        return $ret;
    }
}